<div class="row-fluid">
    <div class="box span12">
        <div class="box-header">
            <h2><i class="icon-user"></i><span class="break"></span>
                <?php echo isset($_GET['pk']) ? 'Edit Item' : 'Create Item'; ?>
            </h2>            
        </div>

        <div class="box-content">
            <div class="row-fluid">
                <?php if (Yii::app()->user->hasFlash('error')): ?>
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <?php echo Yii::app()->user->getFlash('error'); ?>
                    </div>
                <?php endif; ?>
                <?php
                $form = $this->beginWidget('CActiveForm', array(
                    'id'                     => 'user-create-form',
//                    'enableAjaxValidation' => true,
                    'enableClientValidation' => true,
                    'htmlOptions'            => array(
                        'class'   => 'form-horizontal',
                        'enctype' => 'multipart/form-data',
                    ),
                    'focus'                  => array($model, 'name'),
                    'clientOptions'          => array(
                        'validateOnSubmit' => true,
                    ),
                ));
                ?>
                <?php echo CHtml::errorSummary($model); ?>
                <fieldset>
                    <div class="span6">                        
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'service_id', array('class' => 'control-label')); ?>
                            <div class="controls">
                                <?php
                                echo CHtml::dropDownList('Slider[service_id]', $model->service_id, Service::getServices(), array(
                                    'multiple data-rel' => "chosen",
                                    'data-placeholder'  => "Select service..."
                                ));
                                ?>
                            </div>
                        </div>
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'images', array('class' => 'control-label')); ?>
                            <div class ="controls">
                                <div class="user_photo">
                                    <?php if ($model): ?>
                                        <div class="row-fluid box">
                                            <div class="span6">                                        
                                                <img src="<?php echo $model->images ?>" alt="Slider Images">
                                            </div>
                                            <div class="clear"></div>                                    
                                        </div>
                                    <?php else: ?>
                                        <img src="<?php echo $model->publicImages ?>" alt="Slider Images">
                                    <?php endif; ?>
                                </div>
                                <input type="file" name="SliderImages" />
                                <font color="red"><?php echo $form->error($model, 'images'); ?></font>
                            </div>
                        </div>
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'rank', array('class' => 'control-label')) ?>
                            <div class ="controls">         
                                <?php echo $form->textField($model, 'rank'); ?>
                                <font color="red"><?php echo $form->error($model, 'rank'); ?></font>
                            </div>
                        </div>
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'price_from', array('class' => 'control-label')) ?>
                            <div class ="controls">         
                                <div class="input-prepend input-append">
                                    <span class="add-on">$</span>
                                    <?php echo $form->textField($model, 'price_from'); ?>
                                </div>
                                <font color="red"><?php echo $form->error($model, 'price_from'); ?></font>
                            </div>
                        </div>
                        <div class="control-group">
                            <?php echo $form->labelEx($model, 'status', array('class' => 'control-label')) ?>
                            <div class ="controls">         
                                <?php $model->status = $model->status ? $model->status : Slider::STATUS_ACTIVE ?>
                                <?php
                                echo $form->radioButtonList($model, 'status', Slider::getArrayStatus(), array(
                                    'template' => '<label class="radio">{input} {label}</label>'
                                ));
                                ?>
                                <font color="red"><?php echo $form->error($model, 'status'); ?></font>
                            </div>
                        </div>
                    </div>

                    <div class="clearfix"></div>
                    <hr>
                    <?php
                    echo CHtml::submitButton('Save', array('class' => 'btn btn-primary'));
                    ?>
                    <a class="btn btn-back" href="<?php echo Yii::app()->createUrl('slider/index') ?>">Back</a>
                </fieldset>
                <?php $this->endWidget(); ?>
            </div>
        </div>
    </div>
</div>
<script>
    $("#Slider_service_id").chosen({max_selected_options: 1});
</script>